Aiuto per la codifica - pagina 104

 

Grazie mille Mladen .... Sei grande ...

 

Ciao ragazzi!

qualche aiuto per la mia richiesta a pagina 103, per favore? Ho cercato informazioni online ma non sono riuscito a far scattare l'allarme per ogni 5 barre (a partire dall'inizio dell'ora)

Grazie in anticipo

 

Caro Mladen/Mr Tools puoi per favore sistemare questo ea in modo che non riapra il commercio una volta che lo stop o il tp è stato colpito.

File:
 

Aiuto di codifica per lo stop loss

Ciao ragazzi,

Ho questo EA che non riesco a cambiare lo stop loss.

Non importa cosa cambio, non cambia. Vorrei cambiare lo stop loss ad almeno 300. Qualche idea?

Grazie in anticipo

questo è il codice per esso:

// input generico dell'utente

extern double Lots=1.0;

extern int TakeProfit=44;

extern int StopLoss=90;

extern bool RSIMethodA=false;

extern bool RSIMethodB=true;

extern int RSIValue=50;

extern bool AbandonMethodA=true;

extern bool AbandonMethodB=falso;

extern int Abandon=101;

extern bool MoneyManagement=true;

extern int Risk=2;

extern int Slippage=3;

extern bool UseProfitLock=true;

extern int BreakEvenTrigger=25;

extern int BreakEven=3;

extern bool LiveTrading=false;

extern bool AccountIsMini=false;

extern int maxTradesPerPair=1;

extern int MagicNumber=5432;

doppio lotMM;

bool BuySignal=false;

bool SetBuy=falso;

bool SellSignal=falso;

bool SetSell=falso;

// Gestione delle barre

datetime bartime=0;

int bartick=0;

int TradeBars=0;

//+------------------------------------------------------------------+

//| funzione di inizializzazione dell'esperto |

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| funzione di deinizializzazione esperto |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| funzione di avvio esperto |

//+------------------------------------------------------------------+

int start()

{

//----

se (UseProfitLock) ProfitLockStop();

se (AbbandonaMetodoA || AbbandonaMetodoB)

{

RunAbandonCheck();

RunAbandonMethods();

}

if (!SetLotsMM()) return(0);

RunOrderTriggerCalculations();

RunPairSpesificSettings();

RunNewOrderManagement();

//----

return(0);

}

/////////////////////////////////////////////////

// SetLotsMM - Di Robert Cochran http://autoforex.biz

/////////////////////////////////////////////////

bool SetLotsMM()

{

doppio MarginCutoff;

if(!AccountIsMini) MarginCutoff = 1000;

if( AccountIsMini) MarginCutoff = 100;

if(AccountFreeMargin() < MarginCutoff) return(false);

se(MoneyManagement)

{

lotMM = MathCeil(SaldoConto() * Rischio / 10000) / 10;

if(lotMM < 0,1) lotMM = Lotti;

if(lotMM > 1.0) lotMM = MathCeil(lotMM);

// Imporre i limiti della dimensione del lotto

se(LiveTrading)

{

if( AccountIsMini) lotMM = lotMM * 10;

if(!AccountIsMini && lotMM < 1.0) lotMM = 1.0;

}

if(lotMM > 100) lotMM = 100;

}

altrimenti

{

lotMM = Lotti; // Cambia MoneyManagement a 0 se vuoi che il parametro Lotti sia attivo

}

return(true);

}

//+------------------------------------------------------------------+

/////////////////////////////////////////////////

// RunOrderTriggerCalculations

/////////////////////////////////////////////////

bool RunOrderTriggerCalculations()

{

bool RSIPOS=false;

bool RSINEG=false;

// media mobile a 3 periodi sulla barra[1]

double bullMA3=iMA(Symbol(),0,3,0,MODE_EMA,PRICE_CLOSE,1);

// media mobile a 7 periodi sulla barra[1]

double bearMA7=iMA(Symbol(),0,7,0,MODE_EMA,PRICE_CLOSE,1);

// media mobile a 2 periodi sulla barra[2]

double RSI=iRSI(Symbol(),0,2,PRICE_CLOSE,2);

double RSI2=iRSI(Symbol(),0,2,PRICE_CLOSE,1);

// Determinare la polarità di RSI

se (RSIMethodA)

{

if(RSI>RSIValue && RSI2<RSIValue)

{

RSIPOS=vero;

RSINEG=falso;

}

altrimenti RSIPOS=falso;

if(RSIRSIValue)

{

RSIPOS=falso;

RSINEG=vero;

}

altrimenti RSINEG=falso;

}

if (RSIMethodB)

{

if(RSI>RSIValue)

{

RSIPOS=vero;

RSINEG=falso;

}

se(RSI<RSIValue)

{

RSIPOS=falso;

RSINEG=vero;

}

}

if ((bullMA3 > (bearMA7+Point)) && RSINEG)

{

BuySignal=true;

}

altrimenti BuySignal=falso;

se ((bullMA3 < (bearMA7-Point)) && RSIPOS)

{

SellSignal=true;

}

else SellSignal=false;

return(true);

}

/////////////////////////////////////////////////

// Aprire gli ordini per simbolo e commento

/////////////////////////////////////////////////

int OpenOrdersForThisEA()

{

int ofts=0;

for(int x=0;x<OrdersTotal();x++)

{

OrderSelect(x, SELECT_BY_POS, MODE_TRADES);

if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)

{

ofts++;

}

}

return(ofts);

}

/////////////////////////////////////////////////

// PROFIT LOCK - Di Robert Cochran - http://autoforex.biz

/////////////////////////////////////////////////

bool ProfitLockStop()

{

if( OpenOrdersForThisEA() > 0 )

{

for ( int i = 0; i < OrdersTotal(); i++){

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

//--- OPERAZIONI LUNGHE

if(OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber()== MagicNumber)

{

se (Bid >= OrderOpenPrice() + BreakEvenTrigger*Point &&

OrderOpenPrice() > OrderStopLoss())

{

OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + BreakEven * Point, OrderTakeProfit(), Green);

}

}

//--- OPERAZIONI BREVI

if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber()==MagicNumber)

{

if (Ask <= OrderOpenPrice() - BreakEvenTrigger*Point &&

OrderOpenPrice() < OrderStopLoss())

{

OrderModify(OrderTicket(), OrderOpenPrice(),OrderOpenPrice() - BreakEven * Point, OrderTakeProfit(), Blue);

}

}

}

}

}

/////////////////////////////////////////////////

// ABBANDONA IL CONTROLLO

/////////////////////////////////////////////////

bool RunAbandonCheck()

{

if( OpenOrdersForThisEA() > 0 )

{

if (TradeBars == 0 && bartick == 0)

{

for (int i = 0; i < OrdersTotal(); i++)

{

se (OrderSymbol() == Symbol())

{

TradeBars = MathFloor(CurTime() - OrderOpenTime())/60/Period();

bartime = Time[0];

bartick = TradeBars;

}

}

}

if(bartime!=Time[0])

{

bartime=Time[0];

bartick++;

}

}

return(true);

}

/////////////////////////////////////////////////

// RunAbandonMethods

/////////////////////////////////////////////////

bool RunAbandonMethods()

{

if( OpenOrdersForThisEA() > 0 )

{

for (int i = 0; i < OrdersTotal(); i++)

{

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if (AbandonMethodA && bartick==Abandon)//Forza "HEDGE" dopo l'abbandono

{

// TRADING LUNGO

if (OrderType() == OP_BUY && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue);

SetSell=true;

continuare;

}

// COMPRAVENDITE BREVI

if (OrderType() == OP_SELL && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Blue);

SetBuy=true;

continuare;

}

}

if (AbandonMethodB && bartick==Abandon)//Indicatori decidono la direzione dopo l'abbandono

{

// OPERAZIONI LUNGHE

if (OrderType() == OP_BUY && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,White);

continuare;

}

// COMPRAVENDITE BREVI

if (OrderType() == OP_SELL && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);

continuare;

}

}

}

}

return(true);

}

/////////////////////////////////////////////////

// RunPairSpesificSettings

/////////////////////////////////////////////////

bool RunPairSpesificSettings()

{

// imposta le ottimizzazioni dei simboli

if (Simbolo()=="GBPUSD")

{

TakeProfit=55; StopLoss=100; Abandon=69;

}

return(true);

}

/////////////////////////////////////////////////

// EseguiNuovoOrdineGestione

/////////////////////////////////////////////////

bool RunNewOrderManagement()

{

doppio TP,SL;

if( OpenOrdersForThisEA() < maxTradesPerPair )

{

//ENTRY Ask(buy, long)

if (BuySignal || SetBuy)

{

SL = Ask - StopLoss*Point;

TP = Ask + TakeProfit*Point;

OrderSend(Symbol(),OP_BUY,lotMM,Ask,Slippage,SL,TP, "TS-ProfitLock - "+Symbol()+" - Long",MagicNumber,0,White);

bartick=0;

if (SetBuy) SetBuy=falso;

return(true);

}

//ENTRY Bid (sell, short)

if (SellSignal || SetSell)

{

SL = Bid + StopLoss*Point;

TP = Bid - TakeProfit*Point;

OrderSend(Symbol(),OP_SELL,lotMM,Bid,Slippage,SL,TP, "TS-ProfitLock - "+Symbol()+" - Short",MagicNumber,0,Red);

bartick=0;

if (SetSell) SetSell=falso;

return(true);

}

}

return(true);

}

 
graphics:
Ciao ragazzi,

Ho questo EA che non riesco a cambiare lo Stop Loss.

Non importa cosa cambio, non cambierà. Vorrei cambiare lo stop loss ad almeno 300. Qualche idea?

Grazie in anticipo

questo è il codice per esso:

// input generico dell'utente

extern double Lots=1.0;

extern int TakeProfit=44;

extern int StopLoss=90;

extern bool RSIMethodA=false;

extern bool RSIMethodB=true;

extern int RSIValue=50;

extern bool AbandonMethodA=true;

extern bool AbandonMethodB=falso;

extern int Abandon=101;

extern bool MoneyManagement=true;

extern int Risk=2;

extern int Slippage=3;

extern bool UseProfitLock=true;

extern int BreakEvenTrigger=25;

extern int BreakEven=3;

extern bool LiveTrading=false;

extern bool AccountIsMini=false;

extern int maxTradesPerPair=1;

extern int MagicNumber=5432;

doppio lotMM;

bool BuySignal=false;

bool SetBuy=falso;

bool SellSignal=falso;

bool SetSell=falso;

// Gestione delle barre

datetime bartime=0;

int bartick=0;

int TradeBars=0;

//+------------------------------------------------------------------+

//| funzione di inizializzazione dell'esperto |

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| funzione di deinizializzazione esperto |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| funzione di avvio esperto |

//+------------------------------------------------------------------+

int start()

{

//----

se (UseProfitLock) ProfitLockStop();

se (AbbandonaMetodoA || AbbandonaMetodoB)

{

RunAbandonCheck();

RunAbandonMethods();

}

if (!SetLotsMM()) return(0);

RunOrderTriggerCalculations();

RunPairSpesificSettings();

RunNewOrderManagement();

//----

return(0);

}

/////////////////////////////////////////////////

// SetLotsMM - Di Robert Cochran Benvenuto autoforex.biz - BlueHost.com

/////////////////////////////////////////////////

bool SetLotsMM()

{

doppio MarginCutoff;

if(!AccountIsMini) MarginCutoff = 1000;

if( AccountIsMini) MarginCutoff = 100;

if(AccountFreeMargin() < MarginCutoff) return(false);

se(MoneyManagement)

{

lotMM = MathCeil(SaldoConto() * Rischio / 10000) / 10;

if(lotMM < 0,1) lotMM = Lotti;

if(lotMM > 1.0) lotMM = MathCeil(lotMM);

// Imporre i limiti della dimensione del lotto

se(LiveTrading)

{

if( AccountIsMini) lotMM = lotMM * 10;

if(!AccountIsMini && lotMM < 1.0) lotMM = 1.0;

}

if(lotMM > 100) lotMM = 100;

}

altrimenti

{

lotMM = Lotti; // Cambia MoneyManagement a 0 se vuoi che il parametro Lotti sia attivo

}

return(true);

}

//+------------------------------------------------------------------+

/////////////////////////////////////////////////

// RunOrderTriggerCalculations

/////////////////////////////////////////////////

bool RunOrderTriggerCalculations()

{

bool RSIPOS=false;

bool RSINEG=false;

// media mobile a 3 periodi sulla barra[1]

double bullMA3=iMA(Symbol(),0,3,0,MODE_EMA,PRICE_CLOSE,1);

// media mobile a 7 periodi sulla barra[1]

double bearMA7=iMA(Symbol(),0,7,0,MODE_EMA,PRICE_CLOSE,1);

// media mobile a 2 periodi sulla barra[2]

double RSI=iRSI(Symbol(),0,2,PRICE_CLOSE,2);

double RSI2=iRSI(Symbol(),0,2,PRICE_CLOSE,1);

// Determinare la polarità di RSI

se (RSIMethodA)

{

if(RSI>RSIValue && RSI2<RSIValue)

{

RSIPOS=vero;

RSINEG=falso;

}

altrimenti RSIPOS=falso;

se(RSIRSIValue)

{

RSIPOS=falso;

RSINEG=vero;

}

altrimenti RSINEG=falso;

}

if (RSIMethodB)

{

if(RSI>RSIValue)

{

RSIPOS=vero;

RSINEG=falso;

}

se(RSI<RSIValue)

{

RSIPOS=falso;

RSINEG=vero;

}

}

if ((bullMA3 > (bearMA7+Point)) && RSINEG)

{

BuySignal=true;

}

altrimenti BuySignal=falso;

se ((bullMA3 < (bearMA7-Point)) && RSIPOS)

{

SellSignal=true;

}

else SellSignal=false;

return(true);

}

/////////////////////////////////////////////////

// Aprire gli ordini per simbolo e commento

/////////////////////////////////////////////////

int OpenOrdersForThisEA()

{

int ofts=0;

for(int x=0;x<OrdersTotal();x++)

{

OrderSelect(x, SELECT_BY_POS, MODE_TRADES);

if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)

{

ofts++;

}

}

return(ofts);

}

/////////////////////////////////////////////////

// PROFIT LOCK - Di Robert Cochran - Welcome autoforex.biz - BlueHost.com

/////////////////////////////////////////////////

bool ProfitLockStop()

{

if( OpenOrdersForThisEA() > 0 )

{

for ( int i = 0; i < OrdersTotal(); i++){

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

//--- OPERAZIONI LUNGHE

if(OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber()== MagicNumber)

{

se (Bid >= OrderOpenPrice() + BreakEvenTrigger*Point &&

OrderOpenPrice() > OrderStopLoss())

{

OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + BreakEven * Point, OrderTakeProfit(), Green);

}

}

//--- OPERAZIONI BREVI

if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber()==MagicNumber)

{

if (Ask <= OrderOpenPrice() - BreakEvenTrigger*Point &&

OrderOpenPrice() < OrderStopLoss())

{

OrderModify(OrderTicket(), OrderOpenPrice(),OrderOpenPrice() - BreakEven * Point, OrderTakeProfit(), Blue);

}

}

}

}

}

/////////////////////////////////////////////////

// ABBANDONA IL CONTROLLO

/////////////////////////////////////////////////

bool RunAbandonCheck()

{

if( OpenOrdersForThisEA() > 0 )

{

if (TradeBars == 0 && bartick == 0)

{

for (int i = 0; i < OrdersTotal(); i++)

{

se (OrderSymbol() == Symbol())

{

TradeBars = MathFloor(CurTime() - OrderOpenTime())/60/Period();

bartime = Time[0];

bartick = TradeBars;

}

}

}

if(bartime!=Time[0])

{

bartime=Time[0];

bartick++;

}

}

return(true);

}

/////////////////////////////////////////////////

// RunAbandonMethods

/////////////////////////////////////////////////

bool RunAbandonMethods()

{

if( OpenOrdersForThisEA() > 0 )

{

for (int i = 0; i < OrdersTotal(); i++)

{

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if (AbandonMethodA && bartick==Abandon)//Forza "HEDGE" dopo l'abbandono

{

// TRADING LUNGO

if (OrderType() == OP_BUY && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue);

SetSell=true;

continuare;

}

// COMPRAVENDITE BREVI

if (OrderType() == OP_SELL && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Blue);

SetBuy=true;

continuare;

}

}

if (AbandonMethodB && bartick==Abandon)//Indicatori decidono la direzione dopo l'abbandono

{

// OPERAZIONI LUNGHE

if (OrderType() == OP_BUY && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,White);

continuare;

}

// COMPRAVENDITE BREVI

if (OrderType() == OP_SELL && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);

continuare;

}

}

}

}

return(true);

}

/////////////////////////////////////////////////

// RunPairSpesificSettings

/////////////////////////////////////////////////

bool RunPairSpesificSettings()

{

// imposta le ottimizzazioni dei simboli

if (Simbolo()=="GBPUSD")

{

TakeProfit=55; StopLoss=100; Abandon=69;

}

return(true);

}

/////////////////////////////////////////////////

// EseguiNuovoOrdineGestione

/////////////////////////////////////////////////

bool RunNewOrderManagement()

{

doppio TP,SL;

if( OpenOrdersForThisEA() < maxTradesPerPair )

{

//ENTRY Ask(buy, long)

if (BuySignal || SetBuy)

{

SL = Ask - StopLoss*Point;

TP = Ask + TakeProfit*Point;

OrderSend(Symbol(),OP_BUY,lotMM,Ask,Slippage,SL,TP, "TS-ProfitLock - "+Symbol()+" - Long",MagicNumber,0,White);

bartick=0;

if (SetBuy) SetBuy=falso;

return(true);

}

//ENTRY Bid (sell, short)

if (SellSignal || SetSell)

{

SL = Bid + StopLoss*Point;

TP = Bid - TakeProfit*Point;

OrderSend(Symbol(),OP_SELL,lotMM,Bid,Slippage,SL,TP, "TS-ProfitLock - "+Symbol()+" - Short",MagicNumber,0,Red);

bartick=0;

if (SetSell) SetSell=falso;

return(true);

}

}

return(true);

}

Imposterà sempre StopLoss a 100 se il simbolo è GBPUSD

Per gli altri dovrebbe funzionare bene (eccetto che dovresti moltiplicare lo stop loss per 10 per i broker a 5 cifre dato che l'EA lavora con punti e non pip)

 

Lo sto usando su USD/JPY al momento e lo stop loss rimane ancora a 100.

Dove posso trovare il moltiplicatore di stop loss?

 
graphics:
Lo sto usando su USD/JPY al momento e lo stop loss rimane ancora a 100. Dove posso trovare il moltiplicatore di stop loss?

Stop loss e take profit sono impostati in questa parte:

bool RunNewOrderManagement()

{

double TP,SL;

if( OpenOrdersForThisEA() < maxTradesPerPair )

{

//ENTRY Ask(buy, long)

if (BuySignal || SetBuy)

{

SL = Ask - StopLoss*Point;

TP = Ask + TakeProfit*Point;

OrderSend(Symbol(),OP_BUY,lotMM,Ask,Slippage,SL,TP ,"TS-ProfitLock - "+Symbol()+" - Long",MagicNumber,0,White);

bartick=0;

if (SetBuy) SetBuy=false;

return(true);

}

//ENTRY Bid (sell, short)

if (SellSignal || SetSell)

{

SL = Bid + StopLoss*Point;

TP = Bid - TakeProfit*Point;

OrderSend(Symbol(),OP_SELL,lotMM,Bid,Slippage,SL,T P,"TS-ProfitLock - "+Symbol()+" - Short",MagicNumber,0,Red);

bartick=0;

if (SetSell) SetSell=false;

return(true);

}

}

return(true);

}[/PHP]

As of stop loss that stays 100 : this part of code

[PHP]bool RunPairSpesificSettings()

{

// set up the symbol optimizations

if (Symbol()=="GBPUSD")

{

TakeProfit=55; StopLoss=100; Abandon=69;

}

return(true);

}

si attiva solo se il simbolo è "GBPUSD" (come si vede dal codice) quindi solo in quel caso si inverte. Ricontrolla il tuo codice e cerca 100 e troverai cosa sta succedendo con i tuoi stop loss dato che nel codice che hai allegato lo stop loss viene invertito solo nel caso di GBPUSD

 

Ancora non cambia lo stop loss, anche se cambio le coppie di valute con quelle con cui faccio trading. Questo EA sarebbe stato perfetto se lo stop loss potesse essere cambiato

Grazie per aver cercato di aiutare comunque.

 

Ciao codificatori,

Qualcuno potrebbe aiutarmi a modificare questo indicatore squeeze break per avere un'opzione EMA bollinger band e un'opzione EMA keltner channel?

Grazie :)

File:
 
iwillsurvive:
Ciao codificatori,

Qualcuno potrebbe aiutarmi a modificare questo indicatore squeeze break per avere un'opzione EMA bollinger band così come un'opzione EMA keltner channel?

Grazie :)

Ciao Iwillsurvive, ho modificato l'indicatore in modo da avere una scelta di ma in entrambe le bande di keltner e di bollinger, di default è impostato su EMA.

File: