Jump to content
Medved Trader Forums

Recommended Posts

  • 2 weeks later...
Posted

Ok, i see. So it's already prebuilt into it. I probably made a mistake coding it. I'm still learning.

And while you're here could you take a look at my paintbar code for a second and tell me what's going wrong with it? I have a list that contains several objects of the class Pattern. When I run the code, it's supposed to spit out an overall winrate and an overall number of trades on the scan result, and it does. However, when I leave the scan running, it will continue to add the same last value onto the total each second the scan runs, causing the numbers to become really unbalanced. And this only occurs during the case when the last candlestick was a sell signal. I know it sounds strange, but it looks sorta like this when you let the scan run for a while. (The orange bars and sometimes the white bars are the sell candlesticks. You can ignore gray colored numbers. The gray numbers do not change. The orange numbers (and sometimes the whire bars) do change. It's as if the scan continues to add the last trade's profit onto the total, and won't stop doing that until i stop the scan manually). 

By the way, the reason the white bars change sometimes is because. The white signal is supposed to be an entry candlestick. But sometimes the same entry candlestick can also be a sell candlestick for the last trade. So it's like, two signal in one. "Get out of the last trade" and a "get into the next trade" type of signal, built into the same candlestick.

SS 1.png

SS 2.png

SS 3.png

Posted (edited)

So it says in the trader help section that: 

PaintbarState struct that can contain any number of value types. It is very important that only value types are included in that struct, not reference types. There are two instances of the struct - CurrentState and SavedState. All the calculation should be performed using the CurrentState, the SavedState is only there for state-keeping.

For any objects/classes that you need for the state (that is, reference types), you have to do the state-keeping yourself. That would include defining the current/saved copy of the object and the deep-copying between them in the state-saving and state-restoring functions. We provide a very useful class FIFOQueue that would probably be sufficient for most of your needs.

But I don't really know how to do this. I actually have my List<Pattern> variable saved in the PaintbarState struct. It looks like this:

private void PaintbarClearState()

{

CurrentState = new PaintbarState();

...(some other currentstate variables)....

CurrentState.m_listPattern = new List<Pattern> {new pattern("$", new List <double>(), new List <double>(), new List <double>(), new List <double>())};

}

and the scan runs mostly fine (except with the incremental problem above). I don't really know how to start with doing the state-keeping on my own.  I'm not familiar with the currentstate / save state functions. Is there a chance you could take a look at my paintbar and show me how to do it?

Edited by Thebattlefront
Posted

Is it a huge/complex paintbar/scan? Send it to me I will look at it support@medvedtrader.com

The idea with state keeping is that every candle has a state. When you go to next candle, you start with previous candle's state and build on it. When on the last candle, if the previous candle was also last (but not as "complete" as now), your state should revert to the state of the previous candle before processing current candle.

If you have a complex list that contains elements that are also lists, you'd need to implement deep clones in order to keep the state...

As I said, send me the scan I will take a look.

Posted (edited)

Yeah i have a complex list that contains elements that are also lists. Maybe there's a way I can simplify the code so that I don't need lists inside lists, especially if the method to keep the state is going to be overly complex. I was really just trying to practice with classes and objects to better understand how they work. But it'd be cool to know how to save the states of complex lists too, just because you know, it's always good to learn stuff.

Edited by Thebattlefront

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...