//+------------------------------------------------------------------+ #property copyright "Gonario-2009" #property link "winken@inwind.it" //+------------------------------------------------------------------+ extern int DistanceDown_SELL=-6; extern int SL_Down_SELL=3; extern int TP_Down_SELL=40; extern int DistanceUp_SELL=8; extern int SL_Up_SELL=250; extern int TP_Up_SELL=2; extern int DistanceUp_Buy=6; extern int SL_Up_Buy=3; extern int TP_Up_Buy=40; extern int DistanceDown_Buy=-8; extern int SL_Down_Buy=250; extern int TP_Down_Buy=2; double point; int expiration; double price; void init() { Print("point = ", Point," bars=",Bars); } //+------------------------------------------------------------------+ int start() { int i,Total; //int Dgts=MarketInfo(Symbol(),MODE_DIGITS); point=MarketInfo(Symbol(),MODE_POINT); expiration=CurTime()+PERIOD_D1*60; //---------------------------------+ Total=OrdersTotal(); if(Total>0) { for(i=Total-1; i>=0; i--) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); //if(OrderSelect(12345, SELECT_BY_TICKET, MODE_TRADES)==true) { //cas o A - HO VENDUTO: //a1)quando il prezzo arriva a -6 dall'ask //inserisco lo stop a -3 dall'ask //inserisco il take profit a -40 dall'ask if(OrderSymbol()==Symbol() && OrderType()==OP_SELL) if (OrderType() == OP_SELL) price=Ask; { //int StoplossA1=OrderStopLoss(); int StoplossA1; StoplossA1=Ask+SL_Down_SELL*point; //int TakeProfitA1=OrderTakeProfit(); int TakeProfitA1; TakeProfitA1=Ask-TP_Down_SELL*point; if(OrderOpenPrice()-Ask<=point*DistanceDown_SELL) Sleep(500); { OrderModify(OrderTicket(),price,StoplossA1,TakeProfitA1,CurTime()+PERIOD_D1*60,Red); //OrderModify(OrderTicket(),OrderOpenPrice(),StoplossA1,TakeProfitA1,CurTime()+PERIOD_D1*60,Red); //OrderSend(Symbol(),0,0.01,Ask,2,StoplossA1,TakeProfitA1,"My order #1",12345,CurTime()+PERIOD_D1*60,Red); } } ///a2)quando il prezzo arriva a +8 dall'ask //inserisco lo stop loss a +250 dall'ask //inserisco il take profit a -3 dall'ask if(OrderSymbol()==Symbol() && OrderType()==OP_SELL) if (OrderType() == OP_SELL) price=Ask; { //int StoplossA2=OrderStopLoss(); int StoplossA2; StoplossA2=Ask+SL_Up_SELL*point; //int TakeProfitA2=OrderTakeProfit(); int TakeProfitA2; TakeProfitA2=Ask-TP_Up_SELL*point; if(Ask-OrderOpenPrice()>=point*DistanceUp_SELL) Sleep(500); { OrderModify(OrderTicket(),price,StoplossA2,TakeProfitA2,0,Red); //OrderModify(OrderTicket(),OrderOpenPrice(),StoplossA2,TakeProfitA2,0,Red); //OrderSend(Symbol(),0,0.01,Ask,2,StoplossA2,TakeProfitA2,"My order #1",12345,CurTime()+PERIOD_D1*60,Red); } } ////CASO B - HO COMPRATO: //b1)quando il prezzo arriva a +6 dal bid //inserisco lo stop a +3 dal bid //inserisco il take profit a +40 dal bid if (OrderSymbol()==Symbol() && OrderType()==OP_BUY) if (OrderType() == OP_BUY) price=Bid; { //int StoplossB1=OrderStopLoss(); int StoplossB1; StoplossB1=Bid-SL_Up_Buy*point; //int TakeProfitB1=OrderTakeProfit(); int TakeProfitB1; TakeProfitB1=Bid+TP_Up_Buy*point; if(Bid-OrderOpenPrice()>=point*DistanceUp_Buy) Sleep(500); { OrderModify(OrderTicket(),price,StoplossB1,TakeProfitB1,0,Blue); //OrderModify(OrderTicket(),OrderOpenPrice(),StoplossB1,TakeProfitB1,0,Blue); //OrderSend(Symbol(),0,0.01,Ask,2,StoplossB1,TakeProfitB1,"My order #1",12345,CurTime()+PERIOD_D1*60,Green); } } //b2)quando il prezzo arriva a -8 dal bid //inserisco lo stop loss a -250 dal bid //inserisco il take profit a +3 dal bid if (OrderSymbol()==Symbol() && OrderType()==OP_BUY) if (OrderType() == OP_BUY) price=Bid; { //int StoplossB2=OrderStopLoss(); int StoplossB2; StoplossB2=Bid-SL_Down_Buy*point; //int TakeProfitB2=OrderTakeProfit(); int TakeProfitB2; TakeProfitB2=Bid+TP_Down_Buy*point; if(OrderOpenPrice()-Bid<=point*DistanceDown_Buy) Sleep(500); { OrderModify(OrderTicket(),price,StoplossB2,TakeProfitB2,0,Blue); //OrderModify(OrderTicket(),OrderOpenPrice(),StoplossB2,TakeProfitB2,0,Blue); //OrderSend(Symbol(),0,0.01,Ask,2,StoplossB2,TakeProfitB2,"My order #1",12345,CurTime()+PERIOD_D1*60,Green); } } } } } return(0); } //+------------------------------------------------------------------+
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am not a good ones scripter.
I would want an aid for a script program to insert after the start trades
After I have inserted an order at the market of SELL or BUY
I want to activate a script program for
CASE A - AFTER I HAVE SOLD:
a1) when the price arrives to -6 from the ask
I insert the stop to -3 from the ask
I insert the take profit to -40 from the ask
a2) when the price arrives to +8 from the ask
I insert the stop loss to +250 from the ask
I insert the take profit to -3 from the ask
CASE B - AFTER I HAVE BOUGHT:
b1) when the price arrives to +6 from the bid
I insert the stop to +3 from the bid
I insert the take profit to +40 from the bid
b2) when the price arrives to -8 from the bid
I insert the stop loss to -250 from the bid
I insert the take profit to +3 from the bid
My new script, mailed here underneath, does not work.
Why?
Thanks in advance