Where can I post a question on Code?

Section for discussions related to indicators, use of indicators, and building of trading stategies using indicators.

Moderator: admin

Where can I post a question on Code?

Postby AlgyTank » Fri Oct 11, 2024 7:09 am

I would like to incorporate a trading rule that when price is below a certain price for instance USD JPY 148.37 then it will allow a sell based on other parameters. The EA would run on the time frame and currency.
I have all the coding for the mechanics of the sell etc. I just can't find how to reference the currency properly, I created something like the below:

Code: Select all
extern string note24 = "UsePriceZone";
extern bool UsePriceZone = true;
extern double JPYPrice = 148.37;


I am having trouble with my EA referencing a specific currency rate. It could be any currency or rate. E.g. EUR 1.0981 etc.
Any help appreciated
AlgyTank
 
Posts: 2
Joined: Fri Oct 11, 2024 7:03 am

Re: Where can I post a question on Code?

Postby Apprentice » Thu Oct 17, 2024 5:22 pm

We have added your request to the development list.
Development reference 798
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 37884
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Where can I post a question on Code?

Postby Apprentice » Mon Nov 04, 2024 5:04 am

extern string note24 = "UsePriceZone";
extern bool UsePriceZone = true;
// extern double JPYPrice = 148.37; // I prefer to use a generic name (not an specific pair)
extern double PriceZone = 148.37;

// you can use this functions to check if the current price is allowed to buy or sell

bool BuyZoneOk()
{
if (!UsePriceZone)
{
return true;
}

double Ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);

if(Ask >= PriceZone) return true;

return false;

}

bool SellZoneOk()
{
if (!UsePriceZone)
{
return true;
}

double Bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);

if(Bid <= PriceZone) return true;

return false;
}

Code_Question.mq4
(726 Bytes) Downloaded 3 times
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 37884
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Discussions

Who is online

Users browsing this forum: No registered users and 1 guest