Hi,
I am happy to provide you with the attached scalper expert that simply buys and sells when you delete the arrow.
I am happy to provide you with the attached scalper expert that simply buys and sells when you delete the arrow.
Code:
//+------------------------------------------------------------------+
//| fti.mq4 |
//| Copyright © 2017, pannet1 |
//| version 1 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2017, [email protected]"
//+------------------------------------------------------------------+
//| this EA has parts of code from EAs trenor and training2 |
//| the good thing about this ea is that can be used for fti's dance |
//| https://www.forexfactory.com/showthread.php?t=57639. It can be |
//| used for scalping that explains your strategy better. this can |
//| be used for trading manually in the strategy tester without |
//| having to burn your real money. that way you can practice the |
//| dance till heart content. you can also use it for playing trade |
//| game. buy by deleting green arrow and sell by deleting red |
//| you can change the lot size for buy and sell by changing the |
//| respective lots |
//| THIS IS AN OPEN SOURCE EA MADE FOR THE INTEREST OF THE PUBLIC |
//| I ASSUME NO LIABLITY. WHEN YOU USE IT YOU AGREE TO USE IT AT |
//| YOUR OWN RISK |
//+------------------------------------------------------------------+
//| expert initialization function |
#include <stdlib.mqh>//for ErrorDescription
extern int space =10; // the space between the arrows and the highs and lows
extern double lot=0.1; // default lot size for buy and sell market orders
extern color BuyColor=Green;
extern color SellColor=Red;
int Ticket, err;
const double gap = space*Point;
int init()
{
//----
DrawLabels("buyLot", 1, 50, 250, lot, BuyColor ,0);
DrawLabels("buy", 1, 100, 250, "Buy Lot", BuyColor ,0);
DrawLabels("sellLot",3, 50, 250, lot, SellColor ,0);
DrawLabels("sell", 3, 100, 250, "Sell Lot", SellColor,0);
BuyArrow();
SellArrow();
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("up");
ObjectDelete("down");
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//+------------------------------------------------------------------------------------+
//| working with objects |
if(iBarShift(NULL,0,ObjectGet("up",OBJPROP_TIME1))>0
||ObjectGet("up",OBJPROP_PRICE1)!=High[1]+ gap )
{
ObjectMove("up",0, Time[1],High[1]+ gap );
if(ObjectFind("buyLot") != 0) {
DrawLabels("buyLot", 1, 50, 250, lot, BuyColor ,0);
}
}
if(iBarShift(NULL,0,ObjectGet("down",OBJPROP_TIME1))>0
||ObjectGet("down",OBJPROP_PRICE1)!=Low[1]- gap )
{
ObjectMove("down",0, Time[1],Low[1]- gap);
if(ObjectFind("sellLot") != 0) {
DrawLabels("sellLot", 3, 50, 250, lot, SellColor ,0);
}
}
if(ObjectFind("up") != 0) //if no objects
{
BuyOrder();
BuyArrow();
}
if(ObjectFind("down") != 0) //if no objects
{
SellOrder();
SellArrow();
}
//| working with objects |
//+------------------------------------------------------------------------------------+
return(0);
}
//+------------------------------------------------------------------+
void BuyOrder()
{
// find the label and get the lot from its description
if(ObjectFind("buyLot")>-1)
lot=StrToDouble(ObjectDescription("buyLot"));
Ticket=OrderSend(Symbol(),OP_BUY,lot,nd(Ask),3,
0,0,"",0,0,BuyColor);
if(Ticket==-1)
{
err=GetLastError();
Comment("Error of opening Buy ",err,": ",ErrorDescription(err));
}
else
return;
}
void SellOrder()
{
// find the label and get the lot from its description
if(ObjectFind("sellLot")>-1)
lot=StrToDouble(ObjectDescription("sellLot"));
Ticket=OrderSend(Symbol(),OP_SELL,lot,nd(Bid),3,0,0,"",0,0,SellColor);
if(Ticket==-1)
{
err=GetLastError();
Comment("Error of opening Sell ",err,": ",ErrorDescription(err));
}
}
//+------------------------------------------------------------------+
double nd(double in)
{
return(NormalizeDouble(in,Digits));
}
//+------------------------------------------------------------------+
void BuyArrow() {
ObjectCreate("up", OBJ_ARROW, 0, Time[1], High[1]+gap); //draw an up arrow
ObjectSet("up", OBJPROP_STYLE, STYLE_DOT);
ObjectSet("up", OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
// ObjectSet("up", OBJPROP_WIDTH, 5);
ObjectSet("up", OBJPROP_COLOR, BuyColor);
}
void SellArrow() {
ObjectCreate("down", OBJ_ARROW, 0, Time[1], Low[1]-gap); //draw a down arrow
ObjectSet("down", OBJPROP_STYLE, STYLE_DOT);
ObjectSet("down", OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
// ObjectSet("down", OBJPROP_WIDTH, 5);
ObjectSet("down", OBJPROP_COLOR, SellColor);
}
int DrawLabels(string name,int corn,int X,int Y,string Text,color Clr=0,int Win=0,int FSize=18) {
err=ObjectFind(name);
if(err!=Win) {
ObjectCreate(name,OBJ_LABEL,Win,0,0);
} else {
return 0;
}
ObjectSet(name,OBJPROP_CORNER,corn);
ObjectSet(name,OBJPROP_XDISTANCE,X);
ObjectSet(name,OBJPROP_YDISTANCE,Y);
ObjectSetText(name,Text,14,"Arial",Clr);
}