Those are great moments! Keep thinking!SteveHopwood wrote:At the very least, this post has given me the chance to 'think out loud'.
Gday Mark 2
-
VirtualFM
- Trader
- Posts: 84
- Joined: Sat Apr 28, 2012 3:45 am
Re: Gday Mark 2
-
fx800
- Trader
- Posts: 1334
- Joined: Sun Dec 04, 2011 4:11 am
Re: Gday Mark 2
Hi Steve,
For your Gday MK 2 EA, I would like to try using a pending order to buy when a candle cross above the stoch 20, xxx pips above the high of the candle that crosses the stoch 20 + spread.
Is it correct to use the following code
//Long
if (SendLong)
{
type = OP_BUYSTOP;
if (!BuyOpen)
{
price = High[1] + (BufferPips / factor) + (spread / factor);
}//if (!BuyOpen)
}//if (SendLong)
and for sell
//Short
if (SendShort)
{
type = OP_SELLSTOP;
if (!SellOpen)
{
price = Low[1] - (BufferPips / factor) - (spread / factor);
}//if (!SellOpen)
}//if (SendShort)
I have been testing this on demo, and found that the EA places a trade as soon as the stoch crosses the 20/80 line. Not sure why.
Many thanks.
peter
For your Gday MK 2 EA, I would like to try using a pending order to buy when a candle cross above the stoch 20, xxx pips above the high of the candle that crosses the stoch 20 + spread.
Is it correct to use the following code
//Long
if (SendLong)
{
type = OP_BUYSTOP;
if (!BuyOpen)
{
price = High[1] + (BufferPips / factor) + (spread / factor);
}//if (!BuyOpen)
}//if (SendLong)
and for sell
//Short
if (SendShort)
{
type = OP_SELLSTOP;
if (!SellOpen)
{
price = Low[1] - (BufferPips / factor) - (spread / factor);
}//if (!SellOpen)
}//if (SendShort)
I have been testing this on demo, and found that the EA places a trade as soon as the stoch crosses the 20/80 line. Not sure why.
Many thanks.
peter
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Re: Gday Mark 2
A tip for you Peter. Next time you post code, enclose it within afx8000 wrote:Hi Steve,
For your Gday MK 2 EA, I would like to try using a pending order to buy when a candle cross above the stoch 20, xxx pips above the high of the candle that crosses the stoch 20 + spread.
Is it correct to use the following code
//Long
if (SendLong)
{
type = OP_BUYSTOP;
if (!BuyOpen)
{
price = High[1] + (BufferPips / factor) + (spread / factor);
}//if (!BuyOpen)
}//if (SendLong)
and for sell
//Short
if (SendShort)
{
type = OP_SELLSTOP;
if (!SellOpen)
{
price = Low[1] - (BufferPips / factor) - (spread / factor);
}//if (!SellOpen)
}//if (SendShort)
Many thanks.
peter
Code: Select all
Assuming that you have calculated
double spread = (Ask - Bid) * factor
then your code should work. Try it and see.
Here is how code looks when enclosed within
Code: Select all
//Long
if (SendLong)
{
stype = " Buy ";
if (!SendAlertNotTrade)
{
//Got this far, so there is going to be a trade send of some sort. Setting up price here makes
//this code most easily adaptable to easy alteration
price = Ask;//Change this to whatever the price needs to be
take = CalculateTakeProfit(OP_BUY);
stop = CalculateStopLoss(OP_BUY);
//Lot size calculated by risk
if (RiskPercent > 0) SendLots = CalculateLotSize(price, NormalizeDouble(stop, Digits) );
type = OP_BUY;
}//if (!SendAlertNotTrade)
SendTrade = true;
}//if (SendLong)
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
-
fx800
- Trader
- Posts: 1334
- Joined: Sun Dec 04, 2011 4:11 am
Re: Gday Mark 2
Thank you very much, Steve. Sorry didn't know how to use "code : SELLECT ALL" before. This is how the code should look like.
My mistake was using , which I obtained from your Pending order script which you very kindly wrote for one of our members some time ago.
I thought already took account of the factor bit.
I shall try the "double spread =(Ask - Bid)*factor " next week.
Cheers,
peter
Code: Select all
//Long
if (SendLong)
{
type = OP_BUYSTOP;
//price = Ask;//Change this to whatever the price needs to be
if (!BuyOpen)
{
price = High[1] + (BufferPips / factor) + (spread / factor);
}//if (!BuyOpen)
if (!SendAlertNotTrade)
{
take = CalculateTakeProfit(OP_BUY);
stop = CalculateStopLoss(OP_BUY);
//Lot size calculated by risk
if (RiskPercent > 0) SendLots = CalculateLotSize(price, NormalizeDouble(stop, Digits) );
type = OP_BUY;
}//if (!SendAlertNotTrade)
SendTrade = true;
}//if (SendLong)
//Short
if (SendShort)
{
type = OP_SELLSTOP;
//price = Bid;//Change this to whatever the price needs to be
if (!SellOpen)
{
price = Low[1] - (BufferPips / factor) - (spread / factor);
}//if (!SellOpen)
if (!SendAlertNotTrade)
{
take = CalculateTakeProfit(OP_SELL);
stop = CalculateStopLoss(OP_SELL);
//Lot size calculated by risk
if (RiskPercent > 0) SendLots = CalculateLotSize(NormalizeDouble(stop, Digits), price);
type = OP_SELL;
}//if (!SendAlertNotTrade)
SendTrade = true;
}//if (SendShort)Code: Select all
double spread = Ask - Bid;I thought
Code: Select all
(spread / factor)I shall try the "double spread =(Ask - Bid)*factor " next week.
Cheers,
peter
Last edited by Anonymous on Fri Mar 01, 2013 10:44 pm, edited 1 time in total.
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Re: Gday Mark 2
It depends what you want to do. I declare spread purely locally, in DisplayUserFeedback() and IsTradingAllowed()fx8000 wrote:Thank you very much, Steve. Sorry didn't know how to use "code : SELLECT ALL" before.
My mistake was using " double spread = Ask - Bid", which I obtained from your Pending order script which you very kindly wrote for one of our members some time ago.
I shall try the "double spread =(Ask - Bid)*factor " next week.
Cheers,
peter
It may be easier to simply declare spread as a programme-wide variable and read it at the top of start(). I do what I do because I do what I do and it works for me, not because I have some glorious insight into the use of the spread.
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
-
fx800
- Trader
- Posts: 1334
- Joined: Sun Dec 04, 2011 4:11 am
Re: Gday Mark 2
I have put the "double spread" in the wrong place.SteveHopwood wrote:It depends what you want to do. I declare spread purely locally, in DisplayUserFeedback() and IsTradingAllowed()fx8000 wrote:Thank you very much, Steve. Sorry didn't know how to use "code : SELLECT ALL" before.
My mistake was using " double spread = Ask - Bid", which I obtained from your Pending order script which you very kindly wrote for one of our members some time ago.
I shall try the "double spread =(Ask - Bid)*factor " next week.
Cheers,
peter
It may be easier to simply declare spread as a programme-wide variable and read it at the top of start(). I do what I do because I do what I do and it works for me, not because I have some glorious insight into the use of the spread.
I have now moved it to top of Start() as you suggested, like so
Code: Select all
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
double spread = (Ask-Bid)*factor;
//Create a flashing comment if there has been a rogue trade
if (RobotSuspended)
{
while (RobotSuspended)
{
Comment(NL, Gap, "****************** ROBOT SUSPENDED. POSSIBLE ROGUE TRADING ACTIVITY. REMOVE THIE EA IMMEDIATELY ****************** ");
Sleep(2000);
Comment("");
Sleep(1000);
}//while (RobotSuspended)
return;
}//if (RobotSuspended)
//If HG is sleeping after a trade closure, is it time to awake?
if (SafetyViolation) TooClose();
if (SafetyViolation)//TooClose() sets SafetyViolation
{
DisplayUserFeedback();
return;
}//if (SafetyViolation) - SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Re: Gday Mark 2
You still have spread declared as a local variable. It cannot be used throughout your programme unless you pass it to functions as a parameter.
Sorry, but I am tired now and have done the best I can to help. It is up to you to sort things out for yourself now. You will - I did when I started.
Sorry, but I am tired now and have done the best I can to help. It is up to you to sort things out for yourself now. You will - I did when I started.
fx8000 wrote:I have put the "double = spread" in the wrong place.SteveHopwood wrote:It depends what you want to do. I declare spread purely locally, in DisplayUserFeedback() and IsTradingAllowed()fx8000 wrote:Thank you very much, Steve. Sorry didn't know how to use "code : SELLECT ALL" before.
My mistake was using " double spread = Ask - Bid", which I obtained from your Pending order script which you very kindly wrote for one of our members some time ago.
I shall try the "double spread =(Ask - Bid)*factor " next week.
Cheers,
peter
It may be easier to simply declare spread as a programme-wide variable and read it at the top of start(). I do what I do because I do what I do and it works for me, not because I have some glorious insight into the use of the spread.
I have now moved it to top of Start() as you suggested, like so
Code: Select all
//+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- double spread = (Ask-Bid)*factor; //Create a flashing comment if there has been a rogue trade if (RobotSuspended) { while (RobotSuspended) { Comment(NL, Gap, "****************** ROBOT SUSPENDED. POSSIBLE ROGUE TRADING ACTIVITY. REMOVE THIE EA IMMEDIATELY ****************** "); Sleep(2000); Comment(""); Sleep(1000); }//while (RobotSuspended) return; }//if (RobotSuspended) //If HG is sleeping after a trade closure, is it time to awake? if (SafetyViolation) TooClose(); if (SafetyViolation)//TooClose() sets SafetyViolation { DisplayUserFeedback(); return; }//if (SafetyViolation)
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
-
fx800
- Trader
- Posts: 1334
- Joined: Sun Dec 04, 2011 4:11 am
Re: Gday Mark 2
Thank you, Steve. I am sure I will figure things out myself.
Thanks for your help, and have a nice week end.
peter
Thanks for your help, and have a nice week end.
peter
-
fx800
- Trader
- Posts: 1334
- Joined: Sun Dec 04, 2011 4:11 am
Re: Gday Mark 2
fx8000 wrote:Thank you, Steve. I am sure I will figure things out myself.
Thanks for your help, and have a nice week end.
peter
I have solved the problem by adding/subtracting (Ask - Bid) from price, instead of having to declare double spread = (Ask - Bid) * factor again.
Will see if this works tomorrow.
peter
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Re: Gday Mark 2
That is a neat idea - I never thought of that.fx8000 wrote:fx8000 wrote:Thank you, Steve. I am sure I will figure things out myself.
Thanks for your help, and have a nice week end.
peter
I have solved the problem by adding/subtracting (Ask - Bid) from price, instead of having to declare double spread = (Ask - Bid) * factor again.
Will see if this works tomorrow.
peter
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.