Good discussion guys!
cvax, have you tried to run this on any FX pairs? Mainly between 3:00AM EST and 12:00PM EST?
TRO_DYNAMIC_FIBSSR
Moderator: moderators
Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.
Thank you for your support.
cvax wrote:I'm sure the numbers will definitely be profitable in a forward test because of the obvious money just lying there on the table.
That's a bold statement, and contrary to what your backtest (so far) is telling you.
Two of the primary purposes of backtesting are:
1) Providing confidence to place real money on ideas which demonstrably work in backtesting
2) Preventing the placing of real money on ideas which demonstrably do not work in backtesting
Are you backtesting for some other reason?
1) In a scalping strategy as this one backtests are only useful up to the extent of providing a general framework to work off of. You need a forward test to work out the details. Just because the general model is set at a zero-sum game does not mean the detailed version will remain at zero-sum. The way I see it producing a zero-sum general model is GREAT. Most of my other general model's are net-losses. This signifies to me that with fine tuning I might be able to turn this into a net-gain model.
2) My backtest algorithms are overly simplified and do not come close to how the Dynamic_FibsSR should be traded live. I was simply testing to see if a Fibs50% target and Dynamic S/R as stop-loss would be profitable. It turns out that it is not in and of itself, but the true way of using Dynamic_FibsSR (taking what you can quickly) is (very) profitable based on my 10cent analysis. Both of these backtests do not reflect the true nature of the strategy live though, hence the need for forward testing.
Basically the issue here is that I have hit the brick wall of backtesting. Please refer to my earlier posts where I outlined some of the limitations I am facing with my backtesting. You will see why these backtest results are currently inconclusive. Also, realize that even after forwarding testing things may still continue to be inconclusive due to the limitations of forward testing, but the picture will at least be much more clear after my forward tests.
With the backtests I was just hoping for an exceptionally easy use of Dynamic_FibsSR to be profitable, but as it turns out we still have to work for the cash. Cheers.
2) My backtest algorithms are overly simplified and do not come close to how the Dynamic_FibsSR should be traded live. I was simply testing to see if a Fibs50% target and Dynamic S/R as stop-loss would be profitable. It turns out that it is not in and of itself, but the true way of using Dynamic_FibsSR (taking what you can quickly) is (very) profitable based on my 10cent analysis. Both of these backtests do not reflect the true nature of the strategy live though, hence the need for forward testing.
Basically the issue here is that I have hit the brick wall of backtesting. Please refer to my earlier posts where I outlined some of the limitations I am facing with my backtesting. You will see why these backtest results are currently inconclusive. Also, realize that even after forwarding testing things may still continue to be inconclusive due to the limitations of forward testing, but the picture will at least be much more clear after my forward tests.
With the backtests I was just hoping for an exceptionally easy use of Dynamic_FibsSR to be profitable, but as it turns out we still have to work for the cash. Cheers.
-
- rank: 150+ posts
- Posts: 152
- Joined: Sat Jul 29, 2006 9:16 pm
- Reputation: 0
- Location: Geneva, FL
- Gender:
I've been working with Dynamic FIBSSR for awhile now and testing placing limit buy or short orders at the middle fib numbers and watching for a retrace with enough move to pick up a scalp. I haven't backtested or even written a strategy to try this out yet. My experience on a demo account on the ER2 is that .50 can be picked up using 1 minute candles and watching the reversals and Dynamic Fibs SR levels. Successful scalping apparently requires more art and speed than mere techinical codes and backtesting can supply. I'm trying to write this into a strategy in esignal, will let you know if I have any success...
kz
kz
Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.
Thank you for your support.
- TheRumpledOne
- rank: 10000+ posts
- Posts: 15564
- Joined: Sun May 14, 2006 9:31 pm
- Reputation: 3036
- Location: Oregon
- Real name: Avery T. Horton, Jr.
- Gender:
- Contact:
You don't make money backtesting, you make money trading.
If you look at what happens to the price after it puts in dynamic support/resistance and bounces, you'll see there is profit to be made. If you don't then DO NOT use this indicator - it's obviously not for you.
I have added enhancements to help indicate when to enter/exit/stop out of the trade.
The market is dynamic ( most of the time )... the price doesn't just sit there - IT MOVES! And with the "cows", it moves quickly. Sometimes, you only have a split second to grab a dime, other times, you can sit in the trade for a few minutes and collect dollars.
Trading is a skill, like hitting a baseball. You have to trade to get better at trading.
One thing about backtesting, is it is usually PRICE BASED. But when you trade, you are trading against the BID/ASK. That makes a big difference.
Remember, the fib dots are only targets and are not set in stone. No need to give back a profit just because it missed hitting the fib dot by a penny or two.
If you look at what happens to the price after it puts in dynamic support/resistance and bounces, you'll see there is profit to be made. If you don't then DO NOT use this indicator - it's obviously not for you.
I have added enhancements to help indicate when to enter/exit/stop out of the trade.
The market is dynamic ( most of the time )... the price doesn't just sit there - IT MOVES! And with the "cows", it moves quickly. Sometimes, you only have a split second to grab a dime, other times, you can sit in the trade for a few minutes and collect dollars.
Trading is a skill, like hitting a baseball. You have to trade to get better at trading.
One thing about backtesting, is it is usually PRICE BASED. But when you trade, you are trading against the BID/ASK. That makes a big difference.
Remember, the fib dots are only targets and are not set in stone. No need to give back a profit just because it missed hitting the fib dot by a penny or two.
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!
Please do NOT PM me with trading or coding questions, post them in a thread.
Please do NOT PM me with trading or coding questions, post them in a thread.
- Patch
- rank: 500+ posts
- Posts: 941
- Joined: Sat Jan 06, 2007 6:13 pm
- Reputation: 0
- Location: Virginia
- Real name: Jeff
- Gender:
- Contact:
TRO
Great post at 4:07pm. Absolutely on the mark and money about trading being dynamic and based on price via the bid and ask, not a completed bar. Because of these dynamic facts, static back testing has limited usefulness for the live trader. I am yet to meet a trader who makes money trading backtesting results, except ebook and system sellers.
I had an ah-ha moment, with a pardigm shift included. May system sellers and nearly all of the forex brokers offer and suggest that high leverage is a good thing. May I suggest if you and I cannont make money in Forex at 1:1 or up to 5:1, what makes me think I can make money at 50:1 or 100:1? other than blowing out my account 50 to 100% faster? I ask you, is it better to get wiped out by 5 straight losses or 25 or 50?
Plunder and Pillage Pips and Banks Today
Patch
In VA
God Bless You and Protect the USA
Great post at 4:07pm. Absolutely on the mark and money about trading being dynamic and based on price via the bid and ask, not a completed bar. Because of these dynamic facts, static back testing has limited usefulness for the live trader. I am yet to meet a trader who makes money trading backtesting results, except ebook and system sellers.
I had an ah-ha moment, with a pardigm shift included. May system sellers and nearly all of the forex brokers offer and suggest that high leverage is a good thing. May I suggest if you and I cannont make money in Forex at 1:1 or up to 5:1, what makes me think I can make money at 50:1 or 100:1? other than blowing out my account 50 to 100% faster? I ask you, is it better to get wiped out by 5 straight losses or 25 or 50?
Plunder and Pillage Pips and Banks Today
Patch
In VA
God Bless You and Protect the USA
ENOUGH being a Yalie for me Back to the Sea. "What i can lose, i can win" "YES YOU CAN" - dragon33 -"Pick one method and one pair and stick with them until you master it. "The choice is yours - success or failure." TRO
-
- rank: 50+ posts
- Posts: 113
- Joined: Tue Jun 13, 2006 3:42 am
- Reputation: 0
- Location: Atlanta, GA
- Gender:
Well better of course to not get wiped out at all Patch . You are right though, if you can't make money trading without margin then you can't make money trading on margin. However, the beautiful thing about margin is that once your trading is sound, it allows a trader to grow his working capital by starting with a rather small sum of money. The majority of new traders don't have 100k when they place their first trade. Margin is just opportunity for the good traders, and quick cash for the brokerage regarding the bad traders.
After much work in bug fixing this is what I have come up with for DynamicFibsSR backtested.
Looks good in backtesting. Looks good in forward testing so far.
And here is the code
Looks good in backtesting. Looks good in forward testing so far.
And here is the code
Code: Select all
//Plot Trade Triggers
if(showtrades && FirstTickOfBar)
{
//LONG TRADE: If trigger candle touches Dynamic Support and closes above it then enter on the long next bar
if(Low[1]==Support[0] && Support[0]==Support[1] && Close[1]>Low[1]) //Makes sure that we touched Support and retraced on the previous bar and that the Support level has not changed
{
#region Longs
if(High[1]==Resistance[1] && Close[1]<High[1]) return; //Touched both S&R; don't do anything
if(safetrades==true && Open[1]>=Close[1]) return; //Trigger candle is not Green; don't trade next bar
if(firsthour)
{
//Counts trades only happening in first 60mins; disallows trading on first bar of the day
if(ToTime(Time[0]) <= ToTime(Bars.SessionBegin.AddMinutes(60)) && Bars.BarsSinceSession!=0)
{
longs();
}
}
else
{
//Longs (All Day)
if(Bars.BarsSinceSession!=0)
{
longs();
}
}
#endregion
}
//SHORT TRADE: If trigger candle touches Dynamic Support and closes below it then enter short on the next bar
if(High[1]==Resistance[0] && Resistance[0]==Resistance[1] && Close[1]<High[1]) //Makes sure that we touched Resistance and retraced on the previous bar and that the Resistance level has not changed
{
#region Shorts
if(Low[1]==Support[1] && Close[1]>Low[1]) return; //Touched both S&R; don't do anything
if(safetrades==true && Open[1]<=Close[1]) return; //Trigger candle is not Red; don't trade next bar
if(firsthour)
{
if(ToTime(Time[0]) <= ToTime(Bars.SessionBegin.AddMinutes(60)) && Bars.BarsSinceSession!=0)
{
shorts();
}
}
else
{
//Short (All Day)
if(Bars.BarsSinceSession!=0)
{
shorts();
}
}
#endregion
}
}
//Statistics
if(stats && FirstTickOfBar)
{
sdlong = StdDeviation(longscalparray,avglong,longcount);
sdshort = StdDeviation(shortscalparray,avgshort,shortcount);
sdlonggains = StdDeviation(longwinsarray,avglongwins,longwin);
sdlonglosses = StdDeviation(longlossesarray,avglonglosses,(longcount-longwin));
sdshortgains = StdDeviation(shortwinsarray,avgshortwins,shortwin);
sdshortlosses = StdDeviation(shortlossesarray,avgshortlosses,(shortcount-shortwin));
}
#region Miscellaneous
private void longs()
{
#region Long Algorithm
longcount++;
if(Open[0] < Support[1]-0.01) //Do not enter if trade less than stop already
longcount--;
else if(Close[1]>Fib500[1]) //Do not enter trade if trigger candle closed above fib 50%
longcount--;
else
{
DrawDot("Long"+longcount.ToString(),0,DynamicS,Color.Purple);
if(painttrades)
BackColorAll = Color.PaleGreen;
if(stats)
{
TRO_Scalp_Analysis(Input).Direction = TradeDirection.Long;
longscalparray.Add(TRO_Scalp_Analysis(Input)[0]);
longscalp = longscalp + TRO_Scalp_Analysis(Input)[0];
avglong = longscalp / longcount;
if(TROStrategy)
{
//Price fell below stop; trade is a loss
if ( (Open[0]-Low[0] >= Open[0]-Support[1]-0.01) /*&& Open[0] >= Support[1]*/)
{
longlosses=longlosses+shares*((Support[1]-0.01)-Open[0]);
longlossesarray.Add((Support[1]-0.01)-Open[0]);
longlossesscalp = longlossesscalp+((Support[1]-0.01)-Open[0]);
if(debuglong) Print("Long "+longcount+". Date: "+Time[0]+" -"+Math.Round(longlosses,2).ToString("N2")+" Long Losses");
}
//If stop loss not reached then consider these exits
else
{
//Take profit when retraced up to 50% fibs of trigger bar.
if(TRO_Scalp_Analysis(Input)[0] >= (Fib500[1]-Open[0]) )
{
longwins=longwins+shares*(Fib500[1]-Open[0]);
longwin++;
longwinsscalp = longwinsscalp+(Fib500[1]-Open[0]);
longwinsarray.Add(Fib500[1]-Open[0]);
if(debuglong) Print("Long "+longcount+". Date: "+Time[0]+" +"+Math.Round(longwins,2).ToString("N2")+" Long Wins");
}
//No target or stop reached; exit at candle close
else
{
longnullexitcount++;
//Price above open; trade is a win
if(Close[0]>Open[0])
{
longwin++;
longwins=longwins+shares*(Close[0]-Open[0]);
longwinsscalp = longwinsscalp+(Close[0]-Open[0]);
longwinsarray.Add(Close[0]-Open[0]);
if(debuglong) Print("Long "+longcount+". Date: "+Time[0]+" +"+Math.Round(longwins,2).ToString("N2")+" No long exit targets met");
}
//Price below open; trade is a loss
else
{
longlosses=longlosses+shares*(Close[0]-Open[0]);
longlossesarray.Add(Close[0]-Open[0]);
longlossesscalp = longlossesscalp+(Close[0]-Open[0]);
if(debuglong) Print("Long "+longcount+". Date: "+Time[0]+" -"+Math.Round(longlosses,2).ToString("N2")+" No long exit targets met");
}
}
}
avglongwins=longwinsscalp/longwin;
avglonglosses=longlossesscalp/(longcount-longwin);
}
else
{
if(TRO_Scalp_Analysis(Input)[0] > mingains)
{
longwin++;
longwins=longwins+shares*mingains;
longwinsscalp = longwinsscalp+mingains;
longwinsarray.Add(mingains);
}
else
{
longlosses=longlosses+shares*(-1*mingains);
longlossesarray.Add(-1*mingains);
longlossesscalp = longlossesscalp+(-1*mingains);
}
avglongwins=longwinsscalp/longwin;
avglonglosses=longlossesscalp/(longcount-longwin);
}
longwinrate = (longwin/longcount)*100;
}
}
#endregion
}
private void shorts()
{
#region Short Algorithm
shortcount++;
if(Open[0]>Resistance[1]+0.01) //Do not enter if trade above stop already
shortcount--;
if(Close[1]<Fib500[1]) //Do not enter if trigger candle closed below fib 50% (pass price target already)
shortcount--;
else
{
DrawDot("Short"+shortcount.ToString(),0,DynamicR,Color.Crimson);
if(painttrades)
BackColorAll = Color.Pink;
if(stats)
{
TRO_Scalp_Analysis(Input).Direction = TradeDirection.Short;
shortscalparray.Add(TRO_Scalp_Analysis(Input)[0]);
shortscalp = shortscalp + TRO_Scalp_Analysis(Input)[0];
avgshort = shortscalp / shortcount;
if(TROStrategy)
{
//Price move above stop; trade is a loss
if ( (High[0]-Open[0] >= Resistance[1]+0.01-Open[0]) )
{
shortlosses=shortlosses+shares*(Open[0]-(Resistance[1]+0.01));
shortlossesarray.Add(Open[0]-(Resistance[1]+0.01));
shortlossesscalp = shortlossesscalp+(Open[0]-(Resistance[1]+0.01));
avgshortlosses=shortlossesscalp/(shortcount-shortwin);
if(debugshort) Print("Short "+shortcount+". Date: "+Time[0]+" -"+Math.Round(shortlosses,2).ToString("N2")+" Short Losses");
}
//If profit target not reached then consider these exits
else
{
//Take profit when price retraced down to 50% fibs.
if(TRO_Scalp_Analysis(Input)[0] >= (Open[0]-Fib500[1]) )
{
shortwins=shortwins+shares*(Open[0]-Fib500[1]);
shortwinsarray.Add(Open[0]-Fib500[1]);
shortwinsscalp = shortwinsscalp+(Open[0]-Fib500[1]);
shortwin++;
if(debugshort) Print("Short "+shortcount+". Date: "+Time[0]+" +"+Math.Round(shortwins,2).ToString("N2")+" Short Wins");
}
//No target or stop reached; exit at candle close
else
{
shortnullexitcount++;
if(Close[0]<Open[0])
{
shortwin++;
shortwins=shortwins+shares*(Open[0]-Close[0]);
shortwinsarray.Add(Open[0]-Close[0]);
shortwinsscalp = shortwinsscalp+(Open[0]-Close[0]);
if(debugshort) Print("Short "+shortcount+". Date: "+Time[0]+" +"+Math.Round(shortwins,2).ToString("N2")+" No short exit targets met");
}
else
{
shortlosses=shortlosses+shares*(Open[0]-Close[0]);
shortlossesarray.Add(Open[0]-Close[0]);
shortlossesscalp = shortlossesscalp+(Open[0]-Close[0]);
if(debugshort) Print("Short "+shortcount+". Date: "+Time[0]+" -"+Math.Round(shortlosses,2).ToString("N2")+" No short exit targets met");
}
}
}
avgshortwins=shortwinsscalp/shortwin;
avgshortlosses=shortlossesscalp/(shortcount-shortwin);
}
else
{
if(TRO_Scalp_Analysis(Input)[0] > mingains)
{
shortwin++;
shortwins=shortwins+shares*mingains;
shortwinsarray.Add(mingains);
shortwinsscalp=shortwinsscalp+mingains;
}
else
{
shortlosses=shortlosses+shares*(-1*mingains);
shortlossesarray.Add(-1*mingains);
shortlossesscalp=shortlossesscalp+(-1*mingains);
}
avgshortwins=shortwinsscalp/shortwin;
avgshortlosses=shortlossesscalp/(shortcount-shortwin);
}
shortwinrate = (shortwin/shortcount)*100;
}
}
#endregion
}
private double StdDeviation(ArrayList array, double avg, double count)
{
int x = 0;
double sd = 0;
while ( x <count)
{
sd = sd+(( (double) array[x]-avg)*( (double) array[x]-avg));
x++;
}
if (sd>0)
sd = System.Math.Sqrt(sd/(count-1));
return sd;
}
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
{
// Default plotting in base class. Uncomment if indicators holds at least one plot.
base.Plot(graphics, bounds, min, max);
if (stats)
{
//graphics.FillRectangle(new SolidBrush(Color.White), new Rectangle (0, 10, 340, 88));
// plot text in the upper left corner at position 10/10
stringFormatCenter.Alignment = StringAlignment.Center; // text is centered
textBrush.Color = Color.Black; // set text color
#region Column One
//ROW 1
graphics.FillRectangle(new SolidBrush(Color.Gray), bounds.X + 10, bounds.Y + 20, 80, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 10, bounds.Y + 20, 80, 20);
graphics.DrawString("Avg Scalp", textFontBold, textBrush, bounds.X + 50, bounds.Y + 22, stringFormatCenter);
//ROW 2
graphics.FillRectangle(new SolidBrush(Color.LightGoldenrodYellow), bounds.X + 10, bounds.Y + 40, 80, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 10, bounds.Y + 40, 80, 20);
graphics.DrawString("$"+Math.Round(avglong,2).ToString("N2"), textFontBold, textBrush, bounds.X + 50, bounds.Y + 42, stringFormatCenter);
//ROW 3
graphics.FillRectangle(new SolidBrush(Color.LightGoldenrodYellow), bounds.X + 10, bounds.Y + 60, 80, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 10, bounds.Y + 60, 80, 20);
graphics.DrawString("$"+Math.Round(avgshort,2).ToString("N2"), textFontBold, textBrush, bounds.X + 50, bounds.Y + 62, stringFormatCenter);
#endregion
#region Column Two
//ROW 1
graphics.FillRectangle(new SolidBrush(Color.Gray), bounds.X + 90, bounds.Y + 20, 80, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 90, bounds.Y + 20, 80, 20);
graphics.DrawString("Std Dev", textFontBold, textBrush, bounds.X + 90 + 40, bounds.Y + 22, stringFormatCenter);
//ROW 2
graphics.FillRectangle(new SolidBrush(Color.LightGoldenrodYellow), bounds.X + 90, bounds.Y + 40, 80, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 90, bounds.Y + 40, 80, 20);
graphics.DrawString("$"+Math.Round(sdlong,2).ToString("N2"), textFontBold, textBrush, bounds.X + 90 + 40, bounds.Y + 42, stringFormatCenter);
//ROW 3
graphics.FillRectangle(new SolidBrush(Color.LightGoldenrodYellow), bounds.X + 90, bounds.Y + 60, 80, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 90, bounds.Y + 60, 80, 20);
graphics.DrawString("$"+Math.Round(sdshort,2).ToString("N2"), textFontBold, textBrush, bounds.X + 90 + 40, bounds.Y + 62, stringFormatCenter);
#endregion
#region Column Three
//SizeF col2row1 = graphics.MeasureString("% Win " + "(Fib 50%)", textFontBold);
SizeF col2row1;
if(TROStrategy)
col2row1=graphics.MeasureString("% Win " + "(Fib 50%)", textFontBold);
else
col2row1=graphics.MeasureString("% Win " + "($" + mingains.ToString("N2") + ")", textFontBold);
SizeF col2row2 = graphics.MeasureString("$"+longwinrate.ToString("N2")+"%", textFontBold);
SizeF col2row3 = graphics.MeasureString("$"+shortwinrate.ToString("N2")+"%", textFontBold);
if(col2row1.Width>=col2row2.Width)
{
if(col2row1.Width>=col2row3.Width)
col2 = col2row1.Width;
else
col2 = col2row3.Width;
}
else if(col2row2.Width>col2row3.Width)
col2 = col2row2.Width;
else
col2 = col2row3.Width;
if(col2<80)
col2=80;
//ROW 1
graphics.FillRectangle(new SolidBrush(Color.Gray), bounds.X + 170, bounds.Y + 20, col2, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 170, bounds.Y + 20, col2, 20);
if(TROStrategy)
{
graphics.DrawString("% Win " + "(Fib 50%)", textFontBold, textBrush, bounds.X + 170 + col2/2, bounds.Y + 22, stringFormatCenter);
}
else
{
graphics.DrawString("% Win " + "($" + mingains.ToString("N2") + ")", textFontBold, textBrush, bounds.X + 170 + col2/2, bounds.Y + 22, stringFormatCenter);
}
//ROW 2
graphics.FillRectangle(new SolidBrush(Color.LightGoldenrodYellow), bounds.X + 170, bounds.Y + 40, col2, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 170, bounds.Y + 40, col2, 20);
graphics.DrawString(longwinrate.ToString("N2")+"%", textFontBold, textBrush, bounds.X + 170 + col2/2, bounds.Y + 42, stringFormatCenter);
//ROW 3
graphics.FillRectangle(new SolidBrush(Color.LightGoldenrodYellow), bounds.X + 170, bounds.Y + 60, col2, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 170, bounds.Y + 60, col2, 20);
graphics.DrawString(shortwinrate.ToString("N2")+"%", textFontBold, textBrush, bounds.X + 170 + col2/2, bounds.Y + 62, stringFormatCenter);
#endregion
#region Column Four
SizeF col4row1 = graphics.MeasureString("% Win " + "($" + mingains.ToString("N2") + ")", textFontBold);
SizeF col4row2 = graphics.MeasureString(longwinrate.ToString("N2")+"%", textFontBold);
SizeF col4row3 = graphics.MeasureString(shortwinrate.ToString("N2")+"%", textFontBold);
if(col4row1.Width>=col4row2.Width)
{
if(col4row1.Width>=col4row3.Width)
col4 = col4row1.Width;
else
col4 = col4row3.Width;
}
else if(col4row2.Width>col4row3.Width)
col4 = col4row2.Width;
else
col4 = col4row3.Width;
if(col4<80)
col4=80;
//ROW 1
graphics.FillRectangle(new SolidBrush(Color.Gray), bounds.X + 170 + col2, bounds.Y + 20, col4, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 170 + col2, bounds.Y + 20, col4, 20);
graphics.DrawString("Net Gain", textFontBold, textBrush, bounds.X + 170 + col2 + col4/2, bounds.Y + 22, stringFormatCenter);
//ROW 2
graphics.FillRectangle(new SolidBrush(Color.LightGoldenrodYellow), bounds.X + 170 + col2, bounds.Y + 40, col4, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 170 + col2, bounds.Y + 40, col4, 20);
graphics.DrawString("$"+Math.Round(longwins,2).ToString("N2"), textFontBold, textBrush, bounds.X + 170 + col2 + col4/2, bounds.Y + 42, stringFormatCenter);
//ROW 3
graphics.FillRectangle(new SolidBrush(Color.LightGoldenrodYellow), bounds.X + 170 + col2, bounds.Y + 60, col4, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 170 + col2, bounds.Y + 60, col4, 20);
graphics.DrawString("$"+Math.Round(shortwins,2).ToString("N2"), textFontBold, textBrush, bounds.X + 170 + col2 + col4/2, bounds.Y + 62, stringFormatCenter);
#endregion
#region Column Five
SizeF col5row1 = graphics.MeasureString("Net Loss", textFontBold);
SizeF col5row2 = graphics.MeasureString("-$"+Math.Abs(Math.Round(longlosses,2)).ToString("N2"), textFontBold);
SizeF col5row3 = graphics.MeasureString("-$"+Math.Abs(Math.Round(shortlosses,2)).ToString("N2"), textFontBold);
if(col5row1.Width>=col5row2.Width)
{
if(col5row1.Width>=col5row3.Width)
col5 = col5row1.Width;
else
col5 = col5row3.Width;
}
else if(col5row2.Width>col5row3.Width)
col5 = col5row2.Width;
else
col5 = col5row3.Width;
if(col5<80)
col5=80;
//ROW 1
graphics.FillRectangle(new SolidBrush(Color.Gray), bounds.X + 170 + col2 + col4, bounds.Y + 20, col5, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 170 + col2 + col4, bounds.Y + 20, col5, 20);
graphics.DrawString("Net Loss", textFontBold, textBrush, bounds.X + 170 + col2 + col4 + col5/2, bounds.Y + 22, stringFormatCenter);
//ROW 2
graphics.FillRectangle(new SolidBrush(Color.LightGoldenrodYellow), bounds.X + 170 + col2 + col4, bounds.Y + 40, col5, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 170 + col2 + col4, bounds.Y + 40, col5, 20);
graphics.DrawString("-$"+Math.Abs(Math.Round(longlosses,2)).ToString("N2"), textFontBold, textBrush, bounds.X + 170 + col2 + col4 + col5/2, bounds.Y + 42, stringFormatCenter);
//ROW 3
graphics.FillRectangle(new SolidBrush(Color.LightGoldenrodYellow), bounds.X + 170 + col2 + col4, bounds.Y + 60, col5, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 170 + col2 + col4, bounds.Y + 60, col5, 20);
graphics.DrawString("-$"+Math.Abs(Math.Round(shortlosses,2)).ToString("N2"), textFontBold, textBrush, bounds.X + 170 + col2 + col4 + col5/2, bounds.Y + 62, stringFormatCenter);
#endregion
#region Column Six
SizeF col6row1 = graphics.MeasureString("Direction", textFontBold);
SizeF col6row2 = graphics.MeasureString("Long (" + (longwin) + "/" + longcount + " )", textFontBold);
SizeF col6row3 = graphics.MeasureString("Short (" + shortwin + "/" + shortcount + ")", textFontBold);
if(col6row1.Width>=col6row2.Width)
{
if(col6row1.Width>=col6row3.Width)
col6 = col6row1.Width;
else
col6 = col6row3.Width;
}
else if(col6row2.Width>col6row3.Width)
col6 = col6row2.Width;
else
col6 = col6row3.Width;
if(col6<80)
col6=80;
//ROW 1
graphics.FillRectangle(new SolidBrush(Color.Gray), bounds.X + 170 + col2 + col4 + col5, bounds.Y + 20, col6, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 170 + col2 + col4 + col5, bounds.Y + 20, col6, 20);
graphics.DrawString("Direction", textFontBold, textBrush, bounds.X + 170 + col2 + col4 + col5 + col6/2, bounds.Y + 22, stringFormatCenter);
//ROW 2
graphics.FillRectangle(new SolidBrush(Color.LightGoldenrodYellow), bounds.X + 170 + col2 + col4 + col5, bounds.Y + 40, col6, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 170 + col2 + col4 + col5, bounds.Y + 40, col6, 20);
graphics.DrawString("Long (" + (longwin) + "/" + longcount + ")", textFontBold, textBrush, bounds.X + 170 + col2 + col4 + col5 + col6/2, bounds.Y + 42, stringFormatCenter);
//ROW 3
graphics.FillRectangle(new SolidBrush(Color.LightGoldenrodYellow), bounds.X + 170 + col2 + col4 + col5, bounds.Y + 60, col6, 20);
graphics.DrawRectangle(new Pen(Color.Black), bounds.X + 170 + col2 + col4 + col5, bounds.Y + 60, col6, 20);
graphics.DrawString("Short (" + shortwin + "/" + shortcount + ")", textFontBold, textBrush, bounds.X + 170 + col2 + col4 + col5 + col6/2, bounds.Y + 62, stringFormatCenter);
if(advstats)
{
graphics.DrawString("Avg Gains, Std Dev, Avg Losses, Std Dev", textFontBold, textBrush, bounds.X + 170 + col2 + col4 + col5 + col6/2, bounds.Y + 82, stringFormatCenter);
graphics.DrawString("Long: " + avglongwins.ToString("n2") + " " + sdlonggains.ToString("N2") + " " + avglonglosses.ToString("N2") + " " + sdlonglosses.ToString("N2"), textFontBold, textBrush, bounds.X + 170 + col2 + col4 + col5 + col6/2, bounds.Y + 102, stringFormatCenter);
graphics.DrawString("Short: " + avgshortwins.ToString("n2") + " " + sdshortgains.ToString("N2") + " " + avgshortlosses.ToString("N2") + " " + sdshortlosses.ToString("N2"), textFontBold, textBrush, bounds.X + 170 + col2 + col4 + col5 + col6/2, bounds.Y + 122, stringFormatCenter);
}
#endregion
}
}
#endregion
Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.
Thank you for your support.