Come codificare? - pagina 33

 
 

Controllare l'ordine chiuso da TP o SL

ciao

Come controllare se l'ordine è stato chiuso da TP o SL?

master001

 

Aiuto nella codifica!

int k, vOrders;

vOrders = OrdersTotal();

//{

double Profit = 0;

double PipsProfit = 0;

for (k=vOrders-1;k>=0;k--)

{

if (OrderSelect(k, SELECT_BY_POS, MODE_TRADES))

{

if (OrderSymbol()==Symbol() && ((OrderMagicNumber () == Reference) || MagicNumber==0))

{

if (OrderType() == OP_BUY) PipsProfit+ == ((Bid - OrderOpenPrice())/Point);

Profit+= OrderProfit();

else if (OrderType() == OP_SELL) PipsProfit+ = ((OrderOpenPrice() - Ask)/Point);

{

//Profit += OrderProfit();

}

}

}

}

Qualcuno mi ha dato questo codice in passato e ho provato a lavorarci. Mi da degli errori a causa del ' + ' dopo PipsProfit. Qualcuno può fare il debug per me, per favore! Con sincero apprezzamento in anticipo per la vostra assistenza.

Dave

 

if (OrderType() == OP_BUY) PipsProfit+ == ((Bid - OrderOpenPrice())/Point);

[/php]

The + after PipsProfit shouldn't be there at all. It is being used in a comparison NOT an incremental function. You're ASKING does PipsProfit equal Bid - etc etc ?

Try this...

[php]

if ((OrderType() == OP_BUY) && (PipsProfit == (Bid - OrderOpenPrice())/Point)){

// do something IF the above two conditions are TRUE...

}

Buona fortuna

Lux

 

Il problema è che non c'è spazio tra PipsProfit e '+' e uno spazio tra '=' e '+' ...... - in altre parole dovrebbe essere come questo ->

else if (OrderType() == OP_SELL) PipsProfit += ((OrderOpenPrice() - Ask)/Point); {

Dovresti anche includere il secondo 'Profit += OrderProfit();' nel codice(rimuovi quei '//')

 

Domanda sulla codifica

So che un EA può essere codificato per operare solo su conti demo. Posso anche codificare un EA che NON faccia trading su conti PAMM? Questo permetterebbe all'EA di operare su conti live, ma non potrebbe essere usato dai money manager per operare su conti PAMM - a meno che non ci sia un accordo di licenza separato.

 

variabili esterne separate da virgola

Salve,

per un indicatore che uso devo impostare le cifre per ogni simbolo. Lo faccio nel codice con ad es.

if(Symbol()=="GBPJPY" || Symbol()=="EURJPY" || Symbol()=="USDJPY" ....and so on) nDigits = 2;[/PHP]

Now I like to spin these symbols off to an extern variable so that the user can set his symbols for himself. I thought to add sth. like

[PHP]extern string Symbols_nDigits2 = "GBPJPY,EURJPY,USDJPY";

Come posso usare questo elenco di simboli separati da virgola e dividerlo in modo da poterlo usare di nuovo nel codice dell'indicatore come mostrato sopra (if(Symbol()=="GBPJPY"....)?

(O c'è una soluzione migliore per questo "problema di cifre" là fuori?)

Grazie

 
MarketInfo( Symbol(), MODE_DIGITS )
 

perfetto, grazie!

 

L'ho fatto funzionare grazie ad entrambi. Lo apprezzo davvero!

Dave

<<<

Motivazione: