| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Coding for beginners - this is how Steve started https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=301 |
Page 4 of 7 |
| Author: | garyfritz [ Thu Jul 12, 2012 10:58 pm ] |
| Post subject: | Re: Coding for beginners - this is how Steve started |
No, because these "infinite loop" EAs generally process multiple pairs, and Empty4 cannot backtest them. They are for realtime forward testing/trading only. |
|
| Author: | jjasper7 [ Thu Jul 12, 2012 11:37 pm ] |
| Post subject: | Re: Coding for beginners - this is how Steve started |
i am trying to modify some code in simpleshelley, but suspect i am having some array problems that i do not understand. i have inserted alerts (ss3 and ss4) that print proper values for TradePair[][4] as it is being saved, but the printout of alert(ss4) shows only the last movingaverage calculated is saved for ALL instances of TradePair[cc][4] somehow!! i do not understand, can someone please explain what is happening? code: string TradePair[][4]; //jj void ReadTable() { //Fills the array table int cc = 0; double v = 0; string symbol; //jj set TradePair[cc][1] = buyhold; TradePair[cc][2] = buy for (cc = 0; cc < NoOfPairs; cc++) { TradePair[cc][3]=" "; //jj TradePair[cc][4]=" "; //jj symbol = TradePair[cc][0]; Comment(Gap, "Reading the indicators: " + symbol); //Trading time frame Slope //jj int xx,ltp; int lt=Period(); int ltp=240; double Slope = GetSlope(symbol,ltp, 0); //jj current slope !d1 TradePair[cc][3]=DoubleToStr(Slope,2); //jj TradePair[cc][1] = nottradable; if (Slope >= 0.4) TradePair[cc][1] = buyhold; if (Slope <= -0.4) TradePair[cc][1] = sellhold; // market direction double wo = iMA(symbol,ltp,5,1,MODE_LWMA,PRICE_OPEN,0); //jj h4 !w1 double ma = iMA(symbol,lt,1,0,MODE_SMA,PRICE_MEDIAN,0); //jj current price double oma = iMA(symbol,lt,3,0,MODE_SMA,PRICE_MEDIAN,1); //jj past price TradePair[cc][2] = none; TradePair[cc][4]=DoubleToStr(ma,5); //jj Alert( "SS3 ",TradePair[cc][0]," ma",TradePair[cc][3]," a",TradePair[cc][4]," cc",cc); //jj if (ma > wo && ma>oma) TradePair[cc][2] = buy; //jj add direction if (ma < wo && ma<oma) TradePair[cc][2] = sell; //jj }//for (cc = 0 ; cc < ArraySize(TradePair); cc++) Alert("SS2 ",TradePair[0][0]," table calc, ma=", TradePair[0][4]," ", TradePair[1][4]," ", TradePair[2][4]); //jj }//End void ReadTable() |
|
| Author: | jjasper7 [ Fri Jul 13, 2012 1:01 am ] |
| Post subject: | Re: Coding for beginners - this is how Steve started |
the tma slope calculation i get from simpleshelley and from 10.2 tma slope are very different. is there something wrong or is one of them just off in magnitude? i guess the basic question is do they cross zero at about the same time, and the +/- .8 mark need adjustment in shelley? |
|
| Author: | NeoTrader [ Fri Jul 13, 2012 5:40 am ] |
| Post subject: | Re: Coding for beginners - this is how Steve started |
hi jjasper, Just did a quick peek in simple shelley v1b code and the tma code is the standard (repainting) TMA Code. It should be the same value as you see on the standard TMAslope. Have you changed any settings in your slope or are you using a version with TMATrue calculations? happy trading, NeoTrader - |
|
| Author: | fxozgirl [ Sat Jul 14, 2012 5:24 am ] |
| Post subject: | Re: Coding for beginners - this is how Steve started |
Ok, I've decided to dip a toe in the water here and start to learn some coding. Time is my biggest enemy, so will most likely be slow going. Thanks Steve for sharing how you started |
|
| Author: | SteveHopwood [ Sat Jul 14, 2012 10:53 am ] |
| Post subject: | Re: Coding for beginners - this is how Steve started |
Go for it, Tiger. |
|
| Author: | jjasper7 [ Sat Jul 14, 2012 11:23 pm ] |
| Post subject: | Re: Coding for beginners - this is how Steve started |
thanks neo, so i guess that means i am using the wrong tma indi. which is the proper one? also, do you have any ideas that might account for my TradePair[x][4] printout not containing the expected calculated values after exiting the loop? |
|
| Author: | SteveHopwood [ Sat Jul 14, 2012 11:40 pm ] |
| Post subject: | Re: Coding for beginners - this is how Steve started |
Not sure if this helps with your issue, but you might like to go to any of my recent EA's that use Slope and pinch the GetSlope code from there. The code was provided by Baluda, who understands this stuff, and cuts out all the iCustom calls otherwise involved. Sorry if I am barking at the wrong moon here. |
|
| Author: | jjasper7 [ Sun Jul 15, 2012 5:13 am ] |
| Post subject: | Re: Coding for beginners - this is how Steve started |
yea i think the tma code is in shelley and from baluda, and the tma indi i was comparing it against was not the most recent/corrected version. but there are so many instances floating around that i am unclear which is the best stand-alone version to use and that displays the correct recent value. also am assuming the values look alike except in magnitude so am using the one as in the ss code. the outstanding question, though, is still about the array in my code snippet. proper values are stored away and displayed by the ss3 alert, but after the looping is done, the ss2 alert shows that the values for the 4th element of the array was not saved as intended, and i do not see what i did wrong. that 4th element for each instance of the array, contains the same value as last calculated or at least does not contain the value that was calculated for it and gets/displays only the last calculated value. |
|
| Author: | traderduke [ Fri Jul 20, 2012 5:03 pm ] |
| Post subject: | Re: Coding for beginners - this is how Steve started |
Gary with the "run once per candle" removed from the Start(), I'm getting multiple entries in one candle, see the attached. This happens when the "trailing stop" or "take profit" is smaller then the RENKO block. What is the code for limiting one trade per candle?? Thank you for all your help!
|
|
| All times are UTC | Page 4 of 7 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|