Sharp arrow ea mql4 (Denise fiverr)
//+------------------------------------------------------------------+
//| Sharp arrow ea.mq4 |
//| Pulkit Chadha |
//| +918126282062 |
//+------------------------------------------------------------------+
string expiry= "2023.12.16";
string MESSAGE="Trial expired please contact admin";
#property copyright "Pulkit Chadha"
#property link "+918126282062"
#property version "1.00"
#property strict
int i=0,j=0;
extern bool show_arrow=true;
extern bool place_trades=true;
extern double lotsize;
extern int Magic_Number=12345;
extern double Stoploss;
extern double Target;
extern double TSL;
extern string Info="lotsize increase functionality";
extern double increse_account_val=100;
extern double lotsize_multiplier=2;
double megenta,megenta2;
bool BUY=FALSE,SHORT=FALSE;double price,tgt,sll;
string cp,Trade=NULL;
int ticket; int MyDigits;
double MyPoint,profit,tsl_lv,tslmove,PRESENT_BAL,experctedbal,lots; string c;datetime f;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
c =TimeToStr(TimeCurrent(),TIME_DATE);
f = StringToTime(expiry+" "+"9:15"+":00");
if(TimeCurrent()>f)
{
Alert("Trial expired please contact admin ");
ExpertRemove();
}
PRESENT_BAL= AccountBalance();
experctedbal=PRESENT_BAL+increse_account_val;
lots=lotsize;
Alert(PRESENT_BAL);
if(Digits==5)MyDigits=4;
else if(Digits==3)MyDigits=2;
else MyDigits = Digits;
if (Point == 0.00001) MyPoint = 0.0001; //6 digits
else if (Point == 0.001) MyPoint = 0.01; //3 digits (for Yen based pairs)
else MyPoint = Point; //Normal
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
megenta=iCustom(Symbol(),0,"sharp arrow (1)",0,1);
megenta2=iCustom(Symbol(),0,"sharp arrow (1)",0,2);
Comment("megenta= "+megenta+"\nmegenta2= "+megenta2);
if (AccountBalance()>=experctedbal)
{
lots=lots* lotsize_multiplier;
PRESENT_BAL= AccountBalance();
experctedbal=PRESENT_BAL+increse_account_val;
}
if(Close[2]<=megenta2&&Close[1]>megenta&& BUY==FALSE)
{
BUY=true;SHORT=FALSE;
if(show_arrow==true){
buydraw();
}
if(place_trades==true){
closesellposition(lotsize);
price=Ask;Trade="BUY";
if(Target>0){tgt=price+Target*MyPoint;}
if(Stoploss>0){sll=price-Stoploss*MyPoint;}
if (TSL>0){tsl_lv=price+TSL*MyPoint;}
ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,0,sll,tgt,NULL,Magic_Number,0,clrNONE);
}
Alert("BUY @ "+Symbol());
SendNotification("BUY @ "+Symbol());
}
if(Close[2]>=megenta2&&Close[1]<megenta&& SHORT==FALSE)
{
BUY=FALSE;SHORT=true;
if(show_arrow==true){
selldraw();
}
Alert("Sell @ "+Symbol());
SendNotification("Sell @ "+Symbol());
if(place_trades==true){
closebuyposition(lotsize);
price=Bid;Trade="SHORT";
if(Target>0){tgt=price-Target*MyPoint;}
if(Stoploss>0){sll=price+Stoploss*MyPoint;}
if (TSL>0){tsl_lv=price-TSL*MyPoint;}
ticket=OrderSend(Symbol(),OP_SELL,lots,Bid,0,sll,tgt,NULL,Magic_Number,0,clrNONE);
}
}
if (Trade=="BUY")
{
if (Close[0]>=tsl_lv&&tsl_lv>0 )
{
for (int b = OrdersTotal()-1;b>=0;b--)
{
if (OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol()&& OrderType()==OP_BUY)
{
sll=sll+(TSL*MyPoint);
OrderModify(OrderTicket(),OrderOpenPrice(),sll,OrderTakeProfit(),0,clrNONE);
tsl_lv=Close[0]+TSL*MyPoint;
}
}
}
}
}
if (Trade=="SHORT")
{
if (Close[0]<=tsl_lv&&tsl_lv>0 )
{
for (int b = OrdersTotal()-1;b>=0;b--)
{
if (OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol()&& OrderType()==OP_SELL)
{
sll=sll-(TSL*MyPoint);
OrderModify(OrderTicket(),OrderOpenPrice(),sll,OrderTakeProfit(),0,clrNONE);
tsl_lv=Close[0]-TSL*MyPoint;
}
}
}
}
}
}
//+------------------------------------------------------------------+
void closesellposition(double lot_sz)
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
string cp=OrderSymbol();
if(Symbol()==cp)
{
if(OrderType()==OP_SELL)
{
OrderClose(OrderTicket(),lot_sz,Ask,3,NULL);
}
}
}
}
void closebuyposition(double lot_sz)
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
cp = OrderSymbol();
if(Symbol()==cp)
{
if(OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),lot_sz,Bid,3,NULL);
}
}
}
}
void buydraw()
{
ObjectCreate("BUYSIGNAL"+j,OBJ_ARROW_UP,0,Time[0],Low[1]);
ObjectSet("BUYSIGNAL"+j,OBJPROP_COLOR,Blue);
ObjectSet("BUYSIGNAL"+j,OBJPROP_ARROWCODE,233);
ObjectSet("BUYSIGNAL"+j,OBJPROP_WIDTH,3);
ObjectSetInteger(0,"BUYSIGNAL"+j,OBJPROP_ANCHOR,ANCHOR_BOTTOM);
j++;
}
void buydraw2()
{
ObjectCreate("BUYSIGNAL"+j,OBJ_ARROW_UP,0,Time[0],Low[1]);
ObjectSet("BUYSIGNAL"+j,OBJPROP_COLOR,clrLime);
ObjectSet("BUYSIGNAL"+j,OBJPROP_ARROWCODE,233);
ObjectSet("BUYSIGNAL"+j,OBJPROP_WIDTH,3);
ObjectSetInteger(0,"BUYSIGNAL"+j,OBJPROP_ANCHOR,ANCHOR_BOTTOM);
j++;
}
void selldraw()
{
ObjectCreate("ShortSIGNAL"+i,OBJ_ARROW_DOWN,0,Time[0],High[1]);
ObjectSet("ShortSIGNAL"+i,OBJPROP_WIDTH,3);
ObjectSet("ShortSIGNAL"+i,OBJPROP_ARROWCODE,234);
ObjectSet("ShortSIGNAL"+i,OBJPROP_COLOR,Yellow);
ObjectSetInteger(0,"ShortSIGNAL"+i,OBJPROP_ANCHOR,ANCHOR_TOP);
i++;
}
void selldraw2()
{
ObjectCreate("ShortSIGNAL"+i,OBJ_ARROW_DOWN,0,Time[0],High[1]);
ObjectSet("ShortSIGNAL"+i,OBJPROP_WIDTH,3);
ObjectSet("ShortSIGNAL"+i,OBJPROP_ARROWCODE,234);
ObjectSet("ShortSIGNAL"+i,OBJPROP_COLOR,clrPink);
ObjectSetInteger(0,"ShortSIGNAL"+i,OBJPROP_ANCHOR,ANCHOR_TOP);
i++;
}
Comments
Post a Comment