Je feux rentrer long sur x pips plus haut : Stop
Je veux rentrer short sur x pips plus haut :limit
Etc
Etc
Code : #
if signal=1 and not onmarket then
sellshort 1 contract at market
set target pProfit 10
endif
if signal=1 and shortonmarket=1 then
sellshort 1 contract at market
endif
if countofposition=2 then
sellshort at ((tradeprice-tradeprice(2))/2)+tradeprice stop
endifah wais ?falex a écrit :Ça c'est normal c'est le "bug" du backtest dont je t'ai déjà parlé.
En pro-ordre c' est bon.
voici ....reçu ce lundi .....je rempli le formulaire de prt pour le code on verra bien la reponse ....
Code : #
if signal=1 and not onmarket then
sellshort 1 contract at market
set target pProfit 10
endif
if signal=1 and shortonmarket=1 then
sellshort 1 contract at market
endif
if countofposition=-2 then
calcul=((tradeprice+tradeprice(2))/2)
if close > calcul then
exitshort at ((tradeprice+tradeprice(2))/2) limit
else
exitshort at ((tradeprice+tradeprice(2))/2) stop
endif
endifCode : #
//x valeur de votre stop a mettre en variable
if signal=-1 and not onmarket then
buy 1 contract at market
set target pProfit x
endif
if signal=-1 and countofposition=1 then
buy 1 contract at market
set target pProfit 0.001
endif
if signal=1 and not onmarket then
sellshort 1 contract at market
set target pProfit x
endif
if signal=1 and countofposition=-1 then
sellshort 1 contract at market
set target pProfit 0.001
endift sur ?falex a écrit :Pas possible PRT ne sais pas faire de hedging.
Au mieux tu te fais deux backtests l'un avec les short, l'autre avec les long et tu consolides le résultat à la main
Veuillez trouver ci-dessous notre réponse à votre demande d'aide à la programmation.
Le cumul de position longue et courtes simultanément dans une même stratégie n'est pas possible .
L'option force open ( qui permet de trader en postions longue et courtes en même temps) ne s'applique que sur le trading manuel.
Cordialement,
Code : #
// Définition des paramètres du code
DEFPARAM CumulateOrders = true // Cumul des positions désactivé
c1 = signalAchat
c2 = signalVente
once compteurA =0
once compteurV =0
if c1 and shortonmarket then
buy at market
compteurV=0
compteurA=1
endif
if c1 and longonmarket and compteurA=1 then
sellshort at market
compteurV=0
compteurA=2
endif
if c2 and longonmarket then
sellshort at market
compteurV=1
compteurA=0
endif
if c2 and shortonmarket and compteurV=1 then
sellshort at market
buy at market
compteurV=2
compteurA=0
endif
Code : #
compteur = 0
if signalAchat and compteur = 0 then
close = valeur
compteur=1
endif
if compteur=1 and low crosses under valeur-10 then
compteur =0
endif